package save

import (
	"Holidays/model"
	"encoding/json"
	"os"
)

// SaveHolidaysToJSON 将节假日数据保存到JSON文件
func SaveHolidaysToJSON(holidaysMap map[int][]model.Holiday, filename string) error {
	file, err := os.Create(filename)
	if err != nil {
		return err
	}
	defer file.Close()

	// 将holidaysMap编码为JSON
	encoder := json.NewEncoder(file)
	err = encoder.Encode(holidaysMap)
	if err != nil {
		return err
	}
	return nil
}
